this._canHavePowerOff = true;
this._powerOffNeedsAuth = false;
+ this._canHaveReboot = true;
+ this._rebootNeedsAuth = false;
this._canHaveSuspend = true;
function tokenizeKeywords(keywords) {
this._lockdownSettings.connect(`changed::${DISABLE_LOCK_SCREEN_KEY}`,
() => this._updateLockScreen());
- this._lockdownSettings.connect(`changed::${DISABLE_LOG_OUT_KEY}`,
- () => this._updateHaveShutdown());
+ this._lockdownSettings.connect(`changed::${DISABLE_LOG_OUT_KEY}`, () => {
+ this._updateHaveShutdown();
+ this._updateHaveReboot();
+ });
- this._screenSaverSettings.connect(`changed::${RESTART_ENABLED_KEY}`,
- () => this._updateHaveShutdown());
+ this._screenSaverSettings.connect(`changed::${RESTART_ENABLED_KEY}`, () => {
+ this._updateHaveShutdown();
+ this._updateHaveReboot();
+ });
this.forceUpdate();
_sessionUpdated() {
this._updateLockScreen();
this._updatePowerOff();
+ this._updateReboot();
this._updateSuspend();
this._updateMultiUser();
}
// settings and Polkit policy - we don't get change notifications for the
// latter, so their value may be outdated; force an update now
this._updateHaveShutdown();
+ this._updateHaveReboot();
this._updateHaveSuspend();
}
this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY));
this._actions.get(POWER_OFF_ACTION_ID).available = this._canHavePowerOff && !disabled;
this.notify('can-power-off');
+ }
- this._actions.get(RESTART_ACTION_ID).available = this._canHavePowerOff && !disabled;
+ async _updateHaveReboot() {
+ try {
+ const [availability] = await this._session.CanRebootAsync();
+ this._canHaveReboot = availability !== GnomeSession.ActionAvailability.UNAVAILABLE;
+ this._rebootNeedsAuth = availability === GnomeSession.ActionAvailability.CHALLENGE;
+ } catch {
+ this._canHaveReboot = false;
+ this._rebootNeedsAuth = false;
+ }
+ this._updateReboot();
+ }
+
+ _updateReboot() {
+ const disabled = (Main.sessionMode.isLocked &&
+ !this._screenSaverSettings.get_boolean(RESTART_ENABLED_KEY)) ||
+ (Main.sessionMode.isLocked && this._rebootNeedsAuth) ||
+ (Main.sessionMode.isGreeter &&
+ this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY));
+ this._actions.get(RESTART_ACTION_ID).available = this._canHaveReboot && !disabled;
this.notify('can-restart');
}